package com.cityeye.util;

import java.text.DecimalFormat;

public class DeptSummary {
	public static int DEPT_TYPE_JD=0;
	public static int DEPT_TYPE_QU=1;
	
	public static DecimalFormat df=new java.text.DecimalFormat( "#.##"); 

	
	int type = DEPT_TYPE_JD;
	String deptId;
	int successPoint = 0;
	int failurePoint = 0;

	int failureIssueCount = 0;
	int successIssueCount = 0;

	public DeptSummary(String deptId) {
		this.deptId = deptId;
	}

	public void addPoint(Integer point,boolean isSuccess) {
		if(isSuccess){
			successPoint+=point;
		}else{
			failurePoint+=point;
		}
	}


	public void addIssueCount(Integer count,boolean isSuccess) {
		if(isSuccess){
			successIssueCount+=count;
		}else{
			failureIssueCount+=count;
		}
	}
	
	public Integer getPoint(boolean isSuccess) {
		if(isSuccess){
			return successPoint;
		}else{
			return failurePoint;
		}
	}
	
	public int getTotalPoint() {
		return failurePoint+successPoint;
	}	

	public Integer getTotalCount(boolean isSuccess) {
		return successIssueCount+failureIssueCount;
	}
	
	public Integer getIssueCount(boolean isSuccess) {
		if(isSuccess){
			return successIssueCount;
		}else{
			return failureIssueCount;
		}
	}

	public float getPassRatio() {
		return (float)successIssueCount / (float)(successIssueCount + failureIssueCount);
	}
	
	public String getPassRatioStr() {
		return df.format(getPassRatio()*100)+"%";
	}
}